package com.credit.jumu.playcard.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.credit.jumu.playcard.R;
import com.credit.jumu.playcard.bean.ProcessInfo;
import com.credit.jumu.playcard.utils.GlideUtil;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.Inflater;

/**
 * Created by Administrator on 2017/10/31/031.
 */

public class GalleryAdapter extends RecyclerView.Adapter<GalleryAdapter.ViewHolder> {
	public LayoutInflater mInflater;
	public ArrayList<ProcessInfo> mDatas;
	public Context context;

	public GalleryAdapter(Context context, ArrayList<ProcessInfo> datats) {
		mInflater = LayoutInflater.from(context);
		this.mDatas = datats;
		this.context = context;
	}

	public class ViewHolder extends RecyclerView.ViewHolder {
		public ViewHolder(View arg0) {
			super(arg0);
		}

		ImageView mImg;
		TextView mTxt;
		ImageView itemview;
	}


	@Override
	public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
		View view = mInflater.inflate(R.layout.item_process,
				parent, false);
		ViewHolder viewHolder = new ViewHolder(view);
		viewHolder.mImg = (ImageView) view.findViewById(R.id.img);
		viewHolder.mTxt = (TextView) view.findViewById(R.id.showtext);
		viewHolder.itemview = view.findViewById(R.id.itemview);
		return viewHolder;
	}

	@Override
	public void onBindViewHolder(ViewHolder holder, int position) {
		GlideUtil.loadImage(context, mDatas.get(position).getIcon(), holder.mImg);
		holder.mTxt.setText(mDatas.get(position).getText());
		if ((mDatas.size() - position) == 1) {
			holder.itemview.setVisibility(View.GONE);
		}
	}

	@Override
	public int getItemCount() {
		return mDatas.size();
	}

}
